package com.zcm.modules.cxf.interceptor;

import com.zcm.modules.cxf.utils.WebServiceHeaderUtil;
import org.apache.cxf.binding.soap.SoapHeader;
import org.apache.cxf.binding.soap.SoapMessage;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;

import java.util.List;

public class WebserviceResponseHeaderWrapper extends AbstractPhaseInterceptor<SoapMessage> {

    public WebserviceResponseHeaderWrapper(){
        super(Phase.PREPARE_SEND);
    }

    @Override
    public void handleMessage(SoapMessage soapMsg) throws Fault {
        System.out.println("ID:"+getId()+"服务器端--响应头包装器");
        List list =soapMsg.getHeaders();
        SoapHeader responsetHeader=WebServiceHeaderUtil.createResponsetHeader();
        list.add(0,responsetHeader);
    }
}
